package com.lintf.sharding.sphere.controller;

import com.lintf.business.entity.BasicInfo;
import com.lintf.sharding.sphere.service.BasicInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author lin tingfeng
 * @system Mac
 * @data 2024/11/5 16:27
 * @package_name com.lintf.sharding.sphere.controller
 * @project_name sharding-sphere
 * @desc
 */
@RestController
@RequestMapping("/basicInfo")
public class BasicInfoController {

    @Autowired
    private BasicInfoService basicInfoService;

    @GetMapping("/save")
    public void save() {
        List<BasicInfo> list = new ArrayList<>();
        BasicInfo basicInfo1 = new BasicInfo();
        basicInfo1.setCityId("gz");
        basicInfo1.setName("广州林霆锋");
        basicInfo1.setCreateBy("ADMIN");
        basicInfo1.setUpdateBy("ADMIN");
        basicInfo1.setCreateTime(new Date());
        basicInfo1.setUpdateTime(new Date());
        list.add(basicInfo1);
        BasicInfo basicInfo2 = new BasicInfo();
        BeanUtils.copyProperties(basicInfo1, basicInfo2);
        basicInfo2.setCityId("sz");
        basicInfo2.setName("深圳林霆锋");
        list.add(basicInfo2);
        basicInfoService.saveBatch(list);
    }
}
